package tg.edu.fhh.demo.entity;

import java.util.ArrayList;
import java.util.List;

import javax.persistence.Entity;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.ManyToMany;

import com.fasterxml.jackson.annotation.JsonIgnore;

import tg.edu.fhh.demo.custom.BaseEntity;


@Entity
@Inheritance(strategy = InheritanceType.JOINED)
public class SysRole extends BaseEntity<Integer> {

	private String name;
	private String code;

	@ManyToMany(mappedBy = "roles")
//	@JoinTable(name = "role_user", joinColumns = { @JoinColumn(name = "role_id") }, inverseJoinColumns = {
//			@JoinColumn(name = "user_id") })
	@JsonIgnore
	private List<SysUser> users = new ArrayList<>();

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getCode() {
		return code;
	}

	public void setCode(String code) {
		this.code = code;
	}

	public List<SysUser> getUsers() {
		return users;
	}

	public void setUsers(List<SysUser> users) {
		this.users = users;
	}

	public SysRole() {
		super();
	}

	public SysRole(Integer id) {
		super(id);
	}

	@Override
	public String toString() {
		return "SysRole [name=" + name + ", code=" + code + ", users=" + users + ", id=" + getId() + "]";
	}

}
